<template>
  <div></div>
</template>

<script>
import { login, getUserLogin } from '@/api/index'
// import {
//   setToken,
//   setnanxunId,
//   setnanxunRoleId,
//   setnanxunSquardonId,
// } from '@/utils/auth'

export default {
  name: 'allView',
  props: {},
  components: {},
  data() {
    return {
      id: null,
    }
  },
  async created() {
    const hash = window.location.hash
    const match = hash.match(/id=(\d+)/)
    this.id = match ? match[1] : null

    //http://60.188.49.69:8093/#/allView?identity=superManageMent
    const hashString = hash.substring(1)
    const identityMatch = /identity=([^&]+)/.exec(hashString)
    const identity = identityMatch ? identityMatch[1] : null
    // console.log(identity)
    if (identity == 'superManageMent') {
      this.id = 92
    }

    const res2 = await getUserLogin({
      id: this.id,
    })
    // localStorage.setItem('nanxun_id', res2.data.id)
    const res = await login({
      username: this.id ? res2.data.username : 'superManageMent',
      password: this.id ? atob(res2.data.password) : '@Ss123456',
    })
    // console.log(res)
    this.$store.commit('storeToken', res.data)
    // localStorage.setItem('nanxun_token', res.data.token)
    // localStorage.setItem('nanxun_roleId', res.data.role)
    // localStorage.setItem('nanxun_squadron', res.data.squadron)
    // setToken(res.data.token)
    // setnanxunId(res.data.userId)
    // setnanxunRoleId(res.data.role)
    // setnanxunSquardonId(res.data.squadron)
    setTimeout(() => {
      this.$router.push({
        path: 'index',
      })
    }, 500)
  },
  methods: {},
  mounted() {},
  watch: {},
  computed: {},
  filters: {},
}
</script>

<style scoped lang="less"></style>
